package com.xj.utils;

import com.xj.model.Ticket;
import org.joda.time.DateTime;

/**
 * 根据用户id创建ticket对象
 */
public class TicketUtils {

  public static Ticket createTicketByUid(int uid){

    Ticket ticket = new Ticket();
    ticket.setTicket(UuidUtils.generate()); //  ticket随机生成，用户密码是加密。二者不是一个东西
    ticket.setUserId(uid);

    //设置t票过期时间
    DateTime expiredTime = new DateTime();
    expiredTime = expiredTime.plusMonths(3);
    ticket.setExpiredAt(expiredTime.toDate());

    return ticket;
  }

}
